﻿@{
    Layout = null;

    var user = ViewBag.User as IUser ?? User.Identity as IUser;
    var roleNames = "";
    if (user != null) roleNames = user.Roles == null ? "" : user.Roles.Join();

    var cfg = ViewBag.Config as NewLife.Common.SysConfig;

    var title = ViewBag.Title + "";
    if (title != "" && !title.EndsWith(" - ")) { title += " - "; }
    title += cfg.DisplayName;

    var set = NewLife.Cube.Setting.Current;
    var res = set.ResourceUrl;
    if (String.IsNullOrEmpty(res)) res = "/Content";
    res = res.TrimEnd('/');

    var name = cfg == null ? "" : cfg.DisplayName;
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->

    <title>@title</title>
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />

    <link rel="stylesheet" href="@res/adminlte/css/fontawesome-all.min.css" />
    <link rel="stylesheet" href="@res/adminlte/css/adminlte.min.css" />
</head>
<body class="hold-transition sidebar-mini" style="overflow: hidden;">
    @await Html.PartialAsync("_Index_Navbar")
    <!-- Main Sidebar Container -->
    <aside class="main-sidebar sidebar-dark-primary elevation-4">
        <!-- Brand Logo -->
        <a href="/Admin/Index/Main" class="brand-link" target="main">
            <span class="brand-text font-weight-light">@name</span>
        </a>

        <!-- Sidebar -->
        <div class="sidebar">
            <!-- Sidebar user (optional) -->
            <div class="user-panel mt-3 pb-3 mb-3 d-flex">
                <div class="image">
                    <img src="@user.GetAvatarUrl()" class="img-circle elevation-2" alt="@user">
                </div>
                <div class="info" title="@roleNames">
                    <a href="/Admin/User/Info" target="main" class="d-block">@user</a>
                </div>
            </div>

            <!-- Sidebar Menu -->
            <nav class="mt-2">
                @await Html.PartialAsync("_Left")
            </nav>
            <!-- /.sidebar-menu -->
        </div>
        <!-- /.sidebar -->
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <iframe style="width: 100%; height: 100%; margin: 0; padding: 0; border: none;" id="main" name="main" src="@ViewBag.Main"></iframe>
    </div>
    <!-- /.content-wrapper -->

    <!-- jQuery -->
    <script src="@res/js/jquery-3.6.0.min.js"></script>
    <!-- Bootstrap 4 -->
    <script src="@res/adminlte/js/bootstrap.bundle.min.js"></script>
    <!-- AdminLTE -->
    <script src="@res/adminlte/js/adminlte.min.js"></script>

    <script type="text/javascript">
        $(function () {
            var $frmContent = $('#main');
            function fixFrmContentSize() {
                var offset = $frmContent.offset();
                var top = offset.top;
                var height = document.documentElement.clientHeight;
                $frmContent.height(height - top);
            }
            fixFrmContentSize();
            $(window).resize(fixFrmContentSize);

            if (window != top) {
                top.location.href = location.href;
            }
        });

    </script>
</body>
</html>